// server.js
const http = require('http')
const url = require('url')
 
function start(route){
  function onRequest(request, response) {
    // 通过url获取到当前访问路径
    let pathName = url.parse(request.url).pathname 
    console.log('Request for ' + pathName + ' received.')
    route(pathName,response)//集中处理路由
  }
  http.createServer(onRequest).listen(3000)
  console.log('Server has started')
}
exports.start = start